package com.bt.dmdb.model;



import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import org.hibernate.annotations.Type;
import org.joda.time.LocalDateTime;
import com.bt.dmdb.json.converter.JsonDateDeserializer;
import com.bt.dmdb.json.converter.JsonDateSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;


@Entity
@Table(name = "customer_question")
@SuppressWarnings("serial")
public class CustomerQuestion implements java.io.Serializable {

    private Long id;
    private CustomerDetails customer;
    private Question question;
    private char answer;
    private String comment;
    private LoginUser createdBy;
	private LoginUser updatedBy;
	private LocalDateTime creationDate;
	private LocalDateTime modificationDate;	

	
	
	
	
    public CustomerQuestion() {
    }

    public CustomerQuestion(Long id) {
        this.id = id;
    }

    public CustomerQuestion(Long id, char answer) {
        this.id = id;
        this.answer = answer;
    }




	public CustomerQuestion(Long id, CustomerDetails customer,
			Question question, char answer, String comment,
			LoginUser createdBy, LoginUser updatedBy, LocalDateTime creationDate,
			LocalDateTime modificationDate) {
		super();
		this.id = id;
		this.customer = customer;
		this.question = question;
		this.answer = answer;
		this.comment = comment;
		this.createdBy = createdBy;
		this.updatedBy = updatedBy;
		this.creationDate = creationDate;
		this.modificationDate = modificationDate;
	}

	@Id
    //@GeneratedValue
    @GeneratedValue(generator = "customerDocumentIG", strategy = GenerationType.TABLE)
    @TableGenerator(name = "customerDocumentIG", table = "jpa_sequences", pkColumnName = "name", pkColumnValue = "CustomerQuestion", allocationSize = 10, valueColumnName = "next_hi_value")
    @Column(name = "id")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "client_id")
    public CustomerDetails getCustomer() {
        return customer;
    }

    public void setCustomer(CustomerDetails customer) {
        this.customer = customer;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "question_id")
	public Question getQuestion() {
		return question;
	}

	public void setQuestion(Question question) {
		this.question = question;
	}

	@Column(name = "comment", nullable = false, length = 50)
	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}
	
	@Column(name = "answer", nullable = false, length = 50)
	public char getAnswer() {
		return answer;
	}

	public void setAnswer(char answer) {
		this.answer = answer;
	}

	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "created_by")
	public LoginUser getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(LoginUser createdBy) {
		this.createdBy = createdBy;
	}
	
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "updated_by")
	public LoginUser getUpdatedBy() {
		return updatedBy;
	}

	public void setUpdatedBy(LoginUser updatedBy) {
		this.updatedBy = updatedBy;
	}

	



@Column(name = "creation_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)

	public LocalDateTime getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(LocalDateTime creationDate) {
		this.creationDate = creationDate;
	}
	
	
	
	

	@Column(name = "modification_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)
	public LocalDateTime getModificationDate() {
		return modificationDate;
	}

	public void setModificationDate(LocalDateTime modificationDate) {
		this.modificationDate = modificationDate;
	}
	
	

   
}
